// pages/recharge/recharge.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    rechargeprice: ['100', '200', '300', '500', '1000', '1500', '2000', '3000'],
    state: '',
    modelshow: true,
    RechargePrice: '0',
    otherprice: ''
  },

  // 扫描水卡二维码
  scan: function () {
    wx.scanCode({
      success: (res) => {
        this.setData({
          img: res.result
        })
      },
      fail: (res) => {
        console.log(res);
      }
    })
  },

  // 选择充值金额
  selectprice: function (e) {
    this.setData({
      state: e.target.dataset.num,
      RechargePrice: e.target.dataset.price
    });
  },
  // 其他金额
  openmodel: function () {
    var that = this;
    that.setData({
      modelshow: false,
      otherprice: ''
    });
  },
  otherprice: function (e) {
    this.setData({
      otherprice: e.detail.value
    });
  },
  // 取消
  cancelBtn: function () {
    var that = this;
    that.setData({
      modelshow: true
    });
  },
  // 确认
  confirmBtn: function () {
    var that = this;
    that.setData({
      modelshow: true,
      RechargePrice: this.data.otherprice
    });
  }
})